home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pbaseiv.zip / P4DOS009.TIP < prev    next >
Text File  |  1991-12-16  |  2KB  |  78 lines

  1. I often move files from one directory to another. Since I
  2. don't want duplicate files cluttering my disk, I created a
  3. batch file, MOVE.BAT [see listing], that copies and
  4. deletes files with one command.
  5.  
  6. To avoid accidentally deleting important files, I built
  7. safeguards into the batch file that ensure a safe and happy
  8. move. Errors are reported if the destination file already
  9. exists, if you mistype a file name, or if you specify a
  10. nonexistent directory.
  11.  
  12. Bruce Purcell
  13. Elk Grove, California
  14.  
  15. Editor's note: Copy MOVE.BAT to a directory in the current
  16. PATH using the Alt-F command. Then type MOVE <file> <dir>,
  17. where <file> is the pathname of the file to move and <dir>
  18. is the destination. For example, MOVE NAMES.DAT C:\BACKUP
  19. moves NAMES.DAT to C:\BACKUP and then deletes the original
  20. file. If you attempt to move a file to a nonexistent
  21. directory, MOVE.BAT will ask for confirmation before
  22. creating the directory. MOVE.BAT has its limits; because it
  23. looks for `%2\%1' when error checking, the batch file can't
  24. move a file to the root directory.
  25.  
  26. I added a PAUSE command that lets you press <Ctrl>-C after
  27. copying if you want to save the original file. If you don't
  28. want this option, remove the first PAUSE and the three
  29. preceding ECHO statements.
  30.  
  31.  
  32. MOVE.BAT moves a file to a new directory, and then
  33. optionally deletes the original file. (Extract using Alt-F)
  34.  
  35. ---- BEGIN LISTING ----
  36. @echo off
  37. if not exist %1 goto NOFILE
  38. if exist %2\%1 goto FILEERR
  39. goto MOVEIT
  40. :NOFILE
  41. echo %1 not found. Check
  42. echo your typing, then
  43. goto ERREND
  44. :FILEERR
  45. echo %2\%1 already exists.
  46. echo Delete duplicate and
  47. goto ERREND
  48. :MOVEIT
  49. copy %1 %2 >nul
  50. if not exist %2\%1 goto DIRERR
  51. echo %1 moved to %2
  52. echo Press Enter to delete
  53. echo original file, or press
  54. echo Ctrl-C and Y to quit.
  55. pause
  56. del %1
  57. goto END
  58. :DIRERR
  59. echo N | del %2
  60. echo Directory %2 not found.
  61. echo Press Enter to create the
  62. echo directory and move the file
  63. echo or Ctrl-C and Y to quit.
  64. pause
  65. md %2
  66. goto MOVEIT
  67. :ERREND
  68. echo try again.
  69. :END
  70. echo on
  71. ---- END LISTING ----
  72.  
  73. Title: Good Moves
  74. Category: DOS
  75. Issue date: May 1991
  76. Editor: Tom Swan
  77. Supplementary files: NONE
  78.